<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
	<form class="form-horizontal m" id="form-bill-add">
		<div class="form-group">
			<label class="col-sm-3 control-label">充值类型：</label>
			<input type="hidden" id="userJson" th:value="${userJson}">
			<div class="col-sm-8">
				<div class="radio-box">
					<input type="radio" name="billType" checked value="0"><label>自费充值</label>
				</div>
				<div class="radio-box">
					<input type="radio" name="billType" value="1"><label>补贴充值</label>
				</div>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label">充值账户：</label>
			<div class="col-sm-8">
				<select id="userId" name="userId" class="form-control">
					<option>请选择账户</option>
					<option th:each="user:${users}" th:value="${user.userId}" th:text="${user.userName + '（' + user.loginName + '）'}"></option>
				</select>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label">账户余额：</label>
			<div class="col-sm-8">
				<label id="money" name="money" class="control-label" type="text"></label>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label">本次充值：</label>
			<div class="col-sm-8">
				<input id="price" name="price" class="form-control" type="text" required>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label">备注：</label>
			<div class="col-sm-8">
				<input id="remark" name="remark" class="form-control" type="text">
			</div>
		</div>
		<div class="form-group">
			<div class="form-control-static col-sm-offset-9">
				<button type="submit" class="btn btn-primary">提交</button>
				<button onclick="$.modal.close()" class="btn btn-danger" type="button">关闭</button>
			</div>
		</div>
	</form>
</div>
<div th:include="include::footer"></div>
<script th:src="@{/ajax/libs/select/select2.js}"></script>
<script type="text/javascript">
    var prefix = ctx + "finance/bill"
    $("#form-bill-add").validate({
        rules:{
            xxxx:{
                required:true,
            },
        },
        submitHandler: function(form) {
            $.operate.save(prefix + "/add", $('#form-bill-add').serialize());
        }
    });
    $("#userId").change(function(){
        var userArray = JSON.parse($("#userJson").val());
        var id = $(this).val();
        $.each(userArray, function (i, user) {
            if(user.userId == id){
                $("#money").text(user.money || 0);
            }
        })
    });
</script>
</body>
</html>
